//
//  WBStatusBar.swift
//  WeiboTen
//
//  Created by ItHeiMa on 2017/7/9.
//  Copyright © 2017年 itHeima. All rights reserved.
//
import UIKit

class WBStatusBar: UIView {
    ///  转发的button
    lazy var retweetedButton: UIButton = UIButton(text: "30", titleColor: UIColor.lightGray, fontSize: 10, image: "timeline_icon_retweet")
    
    ///  转发的button
    lazy var commentButton: UIButton = UIButton(text: "30", titleColor: UIColor.lightGray, fontSize: 10, image: "timeline_icon_comment")
    
    ///  转发的button
    lazy var prizeButton: UIButton = UIButton(text: "30", titleColor: UIColor.lightGray, fontSize: 10, image: "timeline_icon_unlike")
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        self.backgroundColor = UIColor.white
        
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}

extension WBStatusBar {
    func setupUI () {
        //0. 给自己设背景颜色
        //图片平铺
        self.backgroundColor = UIColor(patternImage: UIImage(named: "timeline_card_bottom_background")!)
        
        //1. 添加子控件
        addSubview(retweetedButton)
        addSubview(commentButton)
        addSubview(prizeButton)
        
        //2. 自动布局
        retweetedButton.snp.makeConstraints { (make) in
            make.left.top.bottom.equalTo(self)
        }
        
        commentButton.snp.makeConstraints { (make) in
            make.top.bottom.equalTo(retweetedButton)
            make.left.equalTo(retweetedButton.snp.right)
            make.width.equalTo(retweetedButton)
        }
        
        prizeButton.snp.makeConstraints { (make) in
            make.top.bottom.right.equalTo(self)
            make.left.equalTo(commentButton.snp.right)
            make.width.equalTo(commentButton)
        }
    }
}



